'use strict';

module.exports = app => {
    const {DataTypes} = app.Sequelize;
    const User = app.model.define('user', {
        id: { 
            type: DataTypes.UUID,
            defaultValue: app.Sequelize.UUIDV4, 
            primaryKey: true,
            notNull: true,
            comment: 'ID'
        },
        name:{type: DataTypes.STRING(10),len:[3,8],notNull: true,unique: true,comment: '昵称'},
        username: {type: DataTypes.STRING(10),len:[3,8],notNull: true,unique: true,comment: '用户名'},
        password: {type: DataTypes.STRING(10),len:[3,8],notNull: true,comment: '密码'},
        ip: {type: DataTypes.STRING(20),isIP: true,comment: 'IP'},
        nation: {type: DataTypes.STRING(20),comment: '国家'},
        province: {type: DataTypes.STRING(20),comment: '省份'},
        city: {type: DataTypes.STRING(20),comment: '城市'},
        district: {type: DataTypes.STRING(20),comment: '区域'},
        adcode: {type: DataTypes.STRING(20),comment: '地区编码'},
        ws_key:{type: DataTypes.STRING(70),comment: 'websocket的key'},
        redirect_url:{type: DataTypes.STRING(20),notNull: true,comment: '重定向'},
        role:{type: DataTypes.INTEGER,notNull: true,comment: '角色'},
        role_authority:{type: DataTypes.STRING(500),notNull: true,comment: '页面权限'},
    },
  );
  User.sync()
  return User;
};